﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Demo.AttachFileServer.Migrations
{
    public partial class init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AlarmInfos",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    AlarmId = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
                    AlarmNo = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
                    AttachCount = table.Column<uint>(type: "INTEGER", nullable: false),
                    TerminalPhoneNo = table.Column<string>(type: "TEXT", maxLength: 12, nullable: false),
                    AlarmTime = table.Column<DateTime>(type: "TEXT", nullable: false),
                    SN = table.Column<byte>(type: "INTEGER", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AlarmInfos", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AttachFiles",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    FileName = table.Column<string>(type: "TEXT", nullable: true),
                    FileSize = table.Column<uint>(type: "INTEGER", nullable: false),
                    Body = table.Column<byte[]>(type: "BLOB", nullable: true),
                    IsOk = table.Column<bool>(type: "INTEGER", nullable: false),
                    AlarmId = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AttachFiles", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "FileRecvRecords",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    FileName = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
                    Bodies = table.Column<byte[]>(type: "BLOB", nullable: true),
                    Offset = table.Column<uint>(type: "INTEGER", nullable: false),
                    Length = table.Column<uint>(type: "INTEGER", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_FileRecvRecords", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_FileRecvRecords_FileName",
                table: "FileRecvRecords",
                column: "FileName");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AlarmInfos");

            migrationBuilder.DropTable(
                name: "AttachFiles");

            migrationBuilder.DropTable(
                name: "FileRecvRecords");
        }
    }
}
